<template>
  <div>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in newsLists" :key='item.id'>
        <router-link :to="'/home/news/info/'+item.id">
          <img class="mui-media-object mui-pull-left" :src="item.img_url">
          <div class="mui-media-body">            
            <h1>{{item.title}}</h1>  
            <p class="mui-ellipsis">
              <span>发表时间：{{item.add_time|dateFormate}}</span>
              <span>评论次数：{{item.click}}</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>
<script>
import { Toast } from 'mint-ui'
export default {
  data(){
    return {
      newsLists:[
        {id:1,title:'幸福',add_time:Date.now(),click:11,img_url:'../../images/shuijiao.jpg'},
        {id:2,title:'木屋',add_time:Date.now(),click:22,img_url:'../../images/muwu.jpg'},
        {id:3,title:'CBD',add_time:Date.now(),click:32,img_url:'../../images/cbd.jpg'}
      ]
    }
  },
  methods:{
    getlist(){
      this.$http.get('getnewslist').then(ret=>{
        if(ret.body.status==0){
          this.newsLists=ret.body.message
        }else{
          Toast('新闻列表加载失败')
        }        
      })
    }
  },
  created(){
    this.getlist()
  }
};
</script>
<style lang="scss" scoped>
h1{
  font-size:14px;
}
p{
  font-size:12px;
  color:rgb(22, 124, 241);
  display: flex;
  justify-content: space-between;
}
</style>
